feat: expose oauth discovery metadata source#1041
Open
DaleSeo wants to merge 2 commits into
Open
Conversation
DaleSeo
marked this pull request as ready for review
July 24, 2026 03:31
jamadeo
previously approved these changes
Jul 24, 2026
alexhancock
reviewed
Jul 24, 2026
| /// Nothing was discovered; the endpoints were synthesized from the base | ||
| /// URL (`/authorize`, `/token`, `/register`) for compatibility with the | ||
| /// 2025-03-26 MCP spec's default-endpoint fallback. The server gave no | ||
| /// evidence that it supports OAuth. |
Contributor
There was a problem hiding this comment.
I would include something here if we're going to have a descriptive comment that metadata discovery is now mandatory in newer versions of the spec, and there is no endpoint-synthesis fallback any more.
DaleSeo
force-pushed
the
fix/oauth-discovery-metadata-source
branch
from
July 24, 2026 15:30
37d76ac to
379be61
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1037
Motivation and Context
AuthorizationManager::discover_metadata()falls back to the legacy default endpoints,/authorize,/token, and/register, based on the base URL when discovery returns nothing. This fallback is required for theauth/2025-03-26-oauth-endpoint-fallbackconformance scenario. However, it makes a successful fallback look the same as metadata that the server actually published. As a result, callers cannot tell whether OAuth metadata was discovered or synthesized for compatibility. That behavior was originally introduced in #507 and changed by #960.This changes
AuthorizationManager::discover_metadata()itself to returnDiscoveredAuthorizationMetadata, which contains both theAuthorizationMetadataand itsAuthorizationMetadataSource. The source distinguishes protected resource metadata, authorization server metadata, and the legacy endpoint fallback;is_discovered()reports whether the server published metadata.Because v3 is still in beta, this makes provenance part of the primary discovery contract now instead of adding a parallel method that would need to be retained long-term. Internal SDK and conformance call sites explicitly extract
.metadata; the discovery order, legacy endpoint synthesis, and conformance behavior remain unchanged.How Has This Been Tested?
Unit tests cover all three sources
Breaking Changes
AuthorizationManager::discover_metadata()now returnsResult<DiscoveredAuthorizationMetadata, AuthError>instead ofResult<AuthorizationMetadata, AuthError>.Callers that need the metadata directly must extract the
metadatafield:Callers can inspect
discovered.sourceor calldiscovered.source.is_discovered()before consuming the metadata.Types of changes
Checklist